#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+10;
int t,n,m,L,V,d[N],v[N],a[N],p[N];
inline int read(){
    int f=1,ans=0;
    char c=getchar();
    while(c>'9'||c<'0'){
        if(c=='-') f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9'){
        ans=ans*10+c-'0';
        c=getchar();
    }
    return ans*f;
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    t=read();
    while(t--){
        int ans=0;
        bool flag=false;
        n=read();m=read();L=read();V=read();
        for(int i=1;i<=n;i++){
            d[i]=read();v[i]=read();a[i]=read();
        }
        for(int i=1;i<=m;i++) p[i]=read();
        for(int i=1;i<=n;i++){
            for(int j=1;j<=m;j++){
                if(p[j]<d[i]) continue;
                double temp=v[i]*v[i]+2*a[i]*(p[j]-d[i]);
                if(temp<0) temp=0;
                if(sqrt(temp)>V&&!flag){
                    ans++;
                    flag=true;
                }
            }
        }
        cout<<ans<<' '<<m-1<<'\n';
    }
    return 0;
}
